home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / dejagnu.lha / dejagnu-1.0.1 / tcl / tests / lsearch.test < prev    next >
Text File  |  1992-11-06  |  2KB  |  46 lines

  1. # Commands covered:  lsearch
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright 1991 Regents of the University of California
  8. # Permission to use, copy, modify, and distribute this
  9. # software and its documentation for any purpose and without
  10. # fee is hereby granted, provided that this copyright notice
  11. # appears in all copies.  The University of California makes no
  12. # representations about the suitability of this software for any
  13. # purpose.  It is provided "as is" without express or implied
  14. # warranty.
  15. #
  16. # $Header: /sprite/src/lib/tcl/tests/RCS/lsearch.test,v 1.1 91/08/21 13:37:25 ouster Exp $ (Berkeley)
  17.  
  18. if {[string compare test [info procs test]] == 1} then {source defs}
  19.  
  20. set x {abcd bbcd 123 234 345}
  21. test lsearch-1.1 {lsearch command} {
  22.     lsearch $x 123
  23. } 2
  24. test lsearch-1.2 {lsearch command} {
  25.     lsearch $x 3456
  26. } -1
  27. test lsearch-1.3 {lsearch command} {
  28.     lsearch $x *5
  29. } 4
  30. test lsearch-1.4 {lsearch command} {
  31.     lsearch $x *bc*
  32. } 0
  33.  
  34. test lsearch-2.1 {lsearch errors} {
  35.     list [catch lsearch msg] $msg
  36. } {1 {wrong # args: should be "lsearch list pattern"}}
  37. test lsearch-2.2 {lsearch errors} {
  38.     list [catch {lsearch a} msg] $msg
  39. } {1 {wrong # args: should be "lsearch list pattern"}}
  40. test lsearch-2.3 {lsearch errors} {
  41.     list [catch {lsearch a b c} msg] $msg
  42. } {1 {wrong # args: should be "lsearch list pattern"}}
  43. test lsearch-2.4 {lsearch errors} {
  44.     list [catch {lsearch "\{" b} msg] $msg
  45. } {1 {unmatched open brace in list}}
  46.